package com.ruide.action;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ruide.dao.bankUsersDAO;
import com.ruide.vo.bankUsers;

/**
 * Servlet implementation class doChangeAction
 */
public class doChangeAction extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public doChangeAction() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String pass1=request.getParameter("pass1");
		String pass2=request.getParameter("pass2");
		String pass3=request.getParameter("pass3");
		Integer userid=new Integer((String)request.getSession().getAttribute("userid"));
		bankUsersDAO dao=new bankUsersDAO();
		if(pass1.equals(dao.findById(userid).getUserpass())){
			if(pass2.equals(pass3)) {
				dao.mergepass(pass2, userid);
			}else {
				response.sendRedirect("no.jsp");
			}
		}else {
			response.sendRedirect("no.jsp");
		}
		response.sendRedirect("main.jsp");
	}

}
